using UnityEngine;
using System.Collections;

public class PauseManager : Menu
{
	
	void Start ()
	{
        for (int i = 0; i < 4; i++)
        {
            base.menuElements[i].material.color = Color.black;
        }
		base._manager = gameObject.GetComponent<MenuManager>();
		base.amount = _manager.amount;
		
		beginNavigationY (limit, yieldReturnControls);
		
	}
	
	void Update ()
	{			
		if(Input.GetAxisRaw("Vertical") != 0)
		{
			base.navigationY();
			this.effectSwitch(actualNavigationPosY);
		}
		
		if(base.hasPressEnter())
		{
			this.executeAction(actualNavigationPosY);
		}		
	}

	public override void effectSwitch (int number)
	{
		if(number != lastNumberY)
		{
			Destroy(base.menuElements[lastNumberY].gameObject.GetComponent<specialFlash>());
			base.menuElements[lastNumberY].material.color = Color.black;
			
			if(!base.menuElements[number].gameObject.GetComponent<specialFlash>())
			base.menuElements[number].gameObject.AddComponent("specialFlash");
		}
		else if(!ready)
		{
			if(!base.menuElements[number].gameObject.GetComponent<specialFlash>())
			base.menuElements[number].gameObject.AddComponent("specialFlash");	
		}
	}
	
	public void ActiveElement()
	{
		int number = actualNavigationPosY;
		base.menuElements[number].gameObject.AddComponent("specialFlash");
	}
	
	public void DesactiveElement()
	{
		int number = actualNavigationPosY;
		if(base.menuElements[lastNumberY].gameObject.GetComponent<specialFlash>())
		{
			Destroy(base.menuElements[number].gameObject.GetComponent<SpecialCube>());
			base.menuElements[number].material.color = Color.black;
		}
	}
	
	public override void executeAction (int number)
	{		
		if (number == 0) 
		{
			DesactiveElement();
			Camera.mainCamera.gameObject.GetComponent<Pause>().Return();
		}
		
		if (number == 1) 
		{
			_manager.changeSceneAtName(Application.loadedLevelName);
			Camera.mainCamera.gameObject.GetComponent<Pause>().audioPause.Stop();
			Camera.mainCamera.gameObject.GetComponent<Pause>().audioPause.Play();
		}
		if (number == 2) 
		{
			_manager.changeSceneAtName("Selection");

		}
		if (number == 3) 
		{
			_manager.changeSceneAtName("MainMenu");
		}
		
		
	}
}

